home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / SAT 2.3.7 / Add-ons / Storage / ScoresStubs.p < prev    next >
Encoding:
Text File  |  1995-09-14  |  3.3 KB  |  127 lines  |  [TEXT/PJMM]

  1. {*** This copy of ScoresStubs modified for <your project here>! ***}
  2.  
  3. {================================================}
  4. {============= Score handling and display ==============}
  5. {================================================}
  6.  
  7. {ScoresStubs is the non-reusable part of the Scores unit in the SAT Add-ons.}
  8. {You should make a copy for your project and modify it to suit your needs.}
  9. {You can change the limits (if any), how scores are drawn etc.}
  10.  
  11.  
  12. unit ScoresStubs;
  13. interface
  14.  
  15. {uses SAT, your globals… as necessary}
  16.     uses
  17.         SAT;
  18.  
  19.     const
  20.         kStringSize = 20;
  21.         kListLength = 10;
  22.         kFirstLimit = 100;    {Limit for special event, i.e. new life}
  23.         kAskHighDlog = 128;    {Id of DLOG resource for asking for name at high score}
  24.         kMargin = 3;            {Margin between the text fields in the high score list}
  25.     var
  26.         gNextLimit: Longint;
  27.  
  28.     procedure DoLimit;                                        {Extra life etc.}
  29.  
  30.     procedure DrawScore (score: Longint);                {Draw score offscreen}
  31.     procedure DrawScoreImmediate (score: Longint);    {Draw score immediately}
  32.  
  33. implementation
  34.  
  35. {DoLimit is called whenever the current limit is reached. Here you should add new lives,}
  36. {show that in any way you see fit, and increase gNextLimit to the next limit! Set gNextLimit}
  37. {to 0 if there are no more limits.}
  38.     procedure DoLimit;
  39.     begin
  40. {lives := lives + 1;}
  41.         gNextLimit := gNextLimit * 2;
  42. {SATSoundPlay(klounkSndH, 15, true);}
  43.     end;
  44.  
  45. {InternalDrawScore draws the score (and optionally more) at the appropriate place.}
  46. {Rewrite this for each program!}
  47.  
  48.     function InternalDrawScore (score: Longint): Rect;
  49.         var
  50.             s: str255;
  51.             r: Rect;
  52.             pn: PenState;
  53.     begin
  54.         GetPenState(pn);
  55.         BackColor(blackColor);
  56.         if gSAT.initDepth > 1 then
  57.             ForeColor(redColor)
  58.         else
  59.             ForeColor(whiteColor);
  60.  
  61.         SetRect(r, 0, 0, gSAT.OffSizeH, 20);
  62.         EraseRect(r);
  63.  
  64. {Önskvärd förbättring: Gör allt resten relativt r!}
  65.  
  66.         NumToString(score, s);
  67.         MoveTo(20, 15);
  68.         DrawString('Score: ');
  69.         MoveTo(70, 15);
  70.         DrawString(s);
  71.  
  72. {NumToString(lives, s);}
  73. {MoveTo(200, 15);}
  74. {DrawString('Lives: ');}
  75. {MoveTo(240, 15);}
  76. {DrawString(s);}
  77.  
  78. {NumToString(level, s);}
  79. {MoveTo(400, 15);}
  80. {DrawString('Level: ');}
  81. {MoveTo(450, 15);}
  82. {DrawString(s);}
  83.         BackColor(whiteColor);
  84.         ForeColor(blackColor);
  85.         SetPenState(pn);
  86.         InternalDrawScore := r;
  87.     end;
  88.  
  89. {DrawScore and DrawScoreImmediate may be useable as they are, as long as you draw}
  90. {your score in gSAT.backScreen. If you don't, you have to modify them.}
  91.  
  92. {DrawScore draws the score in gSAT.backScreen and asks SAT to update in the next}
  93. {turn though SATRun.}
  94.     procedure DrawScore (score: Longint);
  95.         var
  96.             s: str255;
  97.             r: Rect;
  98.             tmpPort: SATPort;
  99.     begin
  100.         SATGetPort(tmpPort);
  101.         SATSetPortBackScreen;
  102.         r := InternalDrawScore(score);
  103.         SATBackChanged(r); {Nya sättet att dunka saker på skärmen!}
  104.         SATSetPort(tmpPort);
  105.     end;
  106.  
  107. {DrawScoreImmediate draws the score in gSAT.backScreen and immediately copies}
  108. {it to screen.}
  109.     procedure DrawScoreImmediate (score: longint);
  110.         var
  111.             s: str255;
  112.             r: Rect;
  113.             tmpPort: SATPort;
  114.     begin
  115.         SATGetPort(tmpPort);
  116.         SATSetPortBackScreen;
  117.         r := InternalDrawScore(score);
  118.         SATSetPortScreen;
  119.         CopyBits(gSAT.backscreen.port^.portbits, gSAT.wind.port^.portBits, r, r, srcCopy, nil);
  120.         SATSetPortOffscreen;
  121.         CopyBits(gSAT.backscreen.port^.portbits, gSAT.offscreen.port^.portBits, r, r, srcCopy, nil);
  122.         SATSetPort(tmpPort);
  123.     end;
  124.  
  125.  
  126.  
  127. end.